﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Collections;
using Gizmox.WebGUI.Forms;
using WaveMaster.Holidays.Club.Domain;

namespace WaveMaster.Holidays.Club.Web
{
    public class UserControlFactory
    {
        Hashtable m_userControlCollection = new Hashtable();
        public const string USER = "User";
        public const string USER_ROLE = "User Role";
        public const string CONFIGURATION = "Configuration";
        public const string TRAVEL_AGENT = "TravelAgent";
        public const string TICKET_PURCHASE = "TicketPurchase";
        public const string PASSPORT = "Passport";
        public const string SEAPORT = "SeaPort";
        public const string VESSEL = "Vessel";
        public const string TRIP = "Trip";
        public const string CHECK_IN = "CheckIn";
        public const string BOOKING = "Booking";
        public const string TRANSFER_PASSENGER = "TransferPassenger";
        public const string CONFIRM_BOOKING_B = "ConfirmBooking_b";
        public const string CONFIRM_BOOKING = "ConfirmBooking";
        public const string TICKET_PURCHASE_REPORT = "TicketPurchaseReport";
        public const string BOOKING_REPORT = "BookingReport";
        public const string TRAVEL_AGENT_REPORT = "TravelAgentReport";
        public const string TRAVEL_AGENT_SUMMARY_REPORT = "TravelAgentSummaryReport";
        public const string BOARDING_CONTROL = "BoardingControl";
        public const string MEMBER_TYPE = "Member Type";
        public const string TICKET_DEDUCTION = "Ticket Deduction";
        public const string TICKET_DEDUCTION_REPORT = "Ticket Deduction Report";
        public const string TICKET_REPORT = "Ticket Report";
        public const string PASSENGER_REPORT = "Passenger Report";


        User m_current_user;
        MainForm m_mainForm;
        
        public UserControlFactory(User current_user, MainForm mainForm)
        {
            m_current_user = current_user;
            m_mainForm = mainForm;
        }

        public UserControl GetUserControl(string key)
        {
            UserControl uc = (UserControl)m_userControlCollection[key];
            if (uc == null)
            {
                switch (key)
                {
                    case USER:
                        m_userControlCollection.Add(key, new UserControlManageUser(USER, m_current_user, m_mainForm));
                        break;
                    case USER_ROLE:
                        m_userControlCollection.Add(key, new UserControlManageUserRole(USER_ROLE, m_current_user, m_mainForm));
                        break;
                    case CONFIGURATION:
                        m_userControlCollection.Add(key, new UserControlConfiguration());
                        break;
                    case TRAVEL_AGENT:
                        m_userControlCollection.Add(key, new UserControlManageTravelAgent(TRAVEL_AGENT, m_current_user, m_mainForm));
                        break;
                    case TICKET_PURCHASE:
                        m_userControlCollection.Add(key, new UserControlTicketPurchase(TICKET_PURCHASE, m_current_user, m_mainForm));
                        break;
                    case PASSPORT:
                        m_userControlCollection.Add(key, new UserControlManagePassport(PASSPORT, m_current_user, m_mainForm));
                        break;
                    case SEAPORT:
                        m_userControlCollection.Add(key, new UserControlManageSeaPort(SEAPORT, m_current_user, m_mainForm));
                        break;
                    case VESSEL:
                        m_userControlCollection.Add(key, new UserControlManageVessel(VESSEL, m_current_user, m_mainForm));
                        break;
                    case TRIP:
                        m_userControlCollection.Add(key, new UserControlManageTrip(TRIP, m_current_user, m_mainForm));
                        break;
                    case BOOKING:
                        m_userControlCollection.Add(key, new UserControlManageBooking(BOOKING, m_current_user, m_mainForm));
                        break;
                    case CHECK_IN:
                        m_userControlCollection.Add(key, new UserControlManageCheckIn(CHECK_IN, m_current_user, m_mainForm));
                        break;
                    case CONFIRM_BOOKING_B:
                        m_userControlCollection.Add(key, new UserControlManageConfirmBooking(CONFIRM_BOOKING_B, m_current_user, m_mainForm));
                        break;
                    case TICKET_PURCHASE_REPORT:
                        m_userControlCollection.Add(key, new UserControlReportTicketPurchase(TICKET_PURCHASE_REPORT, m_current_user, m_mainForm));
                        break;
                    case BOOKING_REPORT:
                        m_userControlCollection.Add(key, new UserControlReportBooking(BOOKING_REPORT, m_current_user, m_mainForm));
                        break;
                    case TRAVEL_AGENT_REPORT:
                        m_userControlCollection.Add(key, new UserControlReportTravelAgent(TRAVEL_AGENT_REPORT, m_current_user, m_mainForm));
                        break;
                    case TRAVEL_AGENT_SUMMARY_REPORT:
                        m_userControlCollection.Add(key, new UserControlReportTravelAgentSummary(TRAVEL_AGENT_SUMMARY_REPORT, m_current_user, m_mainForm));
                        break;
                    case BOARDING_CONTROL:
                        m_userControlCollection.Add(key, new UserControlBoardingControl(BOARDING_CONTROL, m_current_user, m_mainForm));
                        break;
                    case CONFIRM_BOOKING:
                        m_userControlCollection.Add(key, new UserControlCheckInControl(CONFIRM_BOOKING, m_current_user, m_mainForm));
                        break;
                    case MEMBER_TYPE:
                        m_userControlCollection.Add(key, new UserControlManageMemberType(MEMBER_TYPE, m_current_user, m_mainForm));
                        break;
                    case TICKET_DEDUCTION:
                        m_userControlCollection.Add(key, new UserControlTicketDeduction(TICKET_DEDUCTION, m_current_user, m_mainForm));
                        break;
                    case TICKET_DEDUCTION_REPORT:
                        m_userControlCollection.Add(key, new UserControlReportTicketDeduction(TICKET_DEDUCTION_REPORT, m_current_user, m_mainForm));
                        break;
                    case TRANSFER_PASSENGER:
                        m_userControlCollection.Add(key, new UserControlTransferPassenger(TRANSFER_PASSENGER, m_current_user, m_mainForm));
                        break;
                    case TICKET_REPORT:
                        m_userControlCollection.Add(key, new UserControlReportTicket(TICKET_REPORT, m_current_user, m_mainForm));
                        break;
                    case PASSENGER_REPORT:
                        m_userControlCollection.Add(key, new UserControlReportPassenger(PASSENGER_REPORT, m_current_user, m_mainForm));
                        break;
                }
            }
            uc = (UserControl)m_userControlCollection[key];
            return uc;
        }
        public static IList GetFormNames()
        {
            IList m_formNames;
            m_formNames = new ArrayList();
            m_formNames.Add(USER);
            m_formNames.Add(USER_ROLE);
            m_formNames.Add(TRAVEL_AGENT);
            m_formNames.Add(TICKET_PURCHASE);
            m_formNames.Add(PASSPORT);
            m_formNames.Add(SEAPORT);
            m_formNames.Add(VESSEL);
            m_formNames.Add(TRIP);
            m_formNames.Add(CHECK_IN);
            m_formNames.Add(CONFIRM_BOOKING);
            m_formNames.Add(BOOKING);
            m_formNames.Add(TRANSFER_PASSENGER);
            //m_formNames.Add(CONFIRM_BOOKING);
            m_formNames.Add(TICKET_PURCHASE_REPORT);
            m_formNames.Add(BOOKING_REPORT);
            m_formNames.Add(TRAVEL_AGENT_REPORT);
            m_formNames.Add(TRAVEL_AGENT_SUMMARY_REPORT);
            m_formNames.Add(BOARDING_CONTROL);
            m_formNames.Add(MEMBER_TYPE);
            m_formNames.Add(TICKET_DEDUCTION); ;
            m_formNames.Add(TICKET_DEDUCTION_REPORT);
            m_formNames.Add(TICKET_REPORT);
            m_formNames.Add(PASSENGER_REPORT);
            return m_formNames;
        }

        public void ClearUserControls()
        {
            m_userControlCollection.Clear();
        }
    }
}